package com.example.application.contorller;

import java.io.BufferedReader;
import java.io.FileReader;

public class zz {
    static String[] save = new String[50000];
    static float[] num1 = new float[26];
    static float[] num2 = new float[26];
    static float[] num3 = new float[52];
    static char zimu[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    static int i = 0;



    public static void main(String args[]) {
        try {
            System.out.println(System.in);
            FileReader fileReader = new FileReader("D:\\other\\谷歌下载\\level-18-personal-project\\Gone_with_the_wind.txt");
            BufferedReader buf = new BufferedReader(fileReader);
            String bufToString = "";
            String readLine = "";
            String[] myArray = new String[50000];  //100：这个值你自己定义，但不宜过大，要根据你文件的大小了，或者文件的行数
            while((readLine = buf.readLine()) != null){
                myArray[i] = readLine;

                save[i]=myArray[i];
                i++;

            }
        }
        catch (Exception e) {
            // e.printStackTrace();
            System.out.println("连不上");
        }
        int length;
        int j=0;
        int t=0;
        for(t=0;t<i;++t)
        {
            char ss[] = save[t].toCharArray();
            for(j=0;j<ss.length;++j)
            {
                if(ss[j]>='A'&&ss[j]<='Z')
                {int k=(int)ss[j];
                    num1[k-65]++;

                }
                else if(ss[j]>='a'&&ss[j]<='z')
                {int k=(int)ss[j];

                    num2[k-97]++;
                }
            }




        }

/*for(j=0;j<26;++j)
{System.out.println(num2[j]);

    }*/
        float all=0;
        for(j=0;j<26;++j)
        {
            all+=num1[j];
            all+=num2[j];
        }
        for(j=0;j<26;++j)
        {
            num1[j]=num1[j]/all*100;
            num2[j]=num2[j]/all*100;
        }
        for(j=0;j<26;++j)
        {
            num3[j]=num1[j];
            num3[j+26]=num2[j];
        }
        for(j=0;j<52;++j)
        {float[] max = new float[26];
            int[] flag = new int[52];
            int p=0;
            for(t=0;t<52;++t)
            {

                if(num3[t]>max[0])
                {
                    flag[0]=t;
                    max[0]=num3[t];

                }
  /*else if(num3[t]==max[0])
  {
   p++;
   flag[p]=t;
   max[p]=num3[t];
  }*/
            }
 /*for(int k=0;k<p;++k)
 {
  System.out.println(zimu[flag[p]]+":"+max[p]+"%");


 }*/
            System.out.print(zimu[flag[p]]+":");
            float fff=(float)(Math.round(max[p]*100))/100;
            System.out.println(fff+"%");
            num3[flag[p]]=0;
        }
    }
}